package com.ylz.sjzx.sio.core.rule;


import com.ylz.sjzx.sio.core.group.model.GroupRegister;

import java.util.Arrays;
import java.util.List;

/**
 * 简单的服务机器均衡实现
 *
 * @author wiqi
 * @version 1.0
 * @date 2020/12/3
 */
public class RandomLoadBalance implements ILoadBalancer {

    /**
     * 实例
     */
    public static ILoadBalancer instance = new RandomLoadBalance();

    @Override
    public List<GroupRegister> balance(List<GroupRegister> result) {
        int randomIndex = (int) (Math.random() * result.size());
        return Arrays.asList(result.get(randomIndex));
    }
}

